
#include "RumbleEffect.h"
#include "hRandom.h"

RumbleEffect::RumbleEffect(RenderableEntity* _entity, float _fDuration, bool _bEnabled, bool _bLoop, Vector2 _vRumble, float _fFrequency) : SpriteEffect(_entity, _fDuration, _bEnabled, _bLoop)
{
    m_vRumble = _vRumble;
    m_fFrequency = _fFrequency;
}

void RumbleEffect::updateEffect(float _fPerc)
{
    float fRandX = hRandom::getRandom();
    float fRandY = hRandom::getRandom();
    m_entity->setPosition(m_vInitPos + Vector2(m_vRumble.x * fRandX, m_vRumble.y * fRandY));
}

void RumbleEffect::enableEffect(bool _bValue)
{
    if(_bValue)
    {
        m_vInitPos = m_entity->getPosition();
    }
}
